# $LastChangedDate: 2011-09-09 00:10:19 -0400 (Fri, 09 Sep 2011) $
# LEGAL: COPYRIGHT (C) 2010 JIM E. BROOKS WWW.PALOMINO3D.ORG
# Find OpenSceneGraph.
# Output:
# OSG_FOUND
# OSG_INC_DIR
# OSG_LIB_DIR (not OSG_LIBS)
# Notes:
# - See module.txt.
#-------------------------------------------------------------------------------

INCLUDE( CMakeModules/inc_find.cmake )

#-------------------------------------------------------------------------------
# Find include directory : OSG_INC_DIR

FIND_PATH( OSG_INC_DIR
    NAMES osg/Node
    PATHS ${POSSIBLE_OSG_INC_DIRS}
)

#-------------------------------------------------------------------------------
# Find library *DIRECTORY* : OSG_LIB_DIR (not OSG_LIBS)

FIND_PATH( OSG_LIB_DIR
    NAMES libosg libosg.so libosg.dylib osg.lib  # unlike FIND_LIBRARY()
    PATHS ${POSSIBLE_OSG_LIB_DIRS}
)

#-------------------------------------------------------------------------------
# Found everything?

IF( OSG_INC_DIR AND OSG_LIB_DIR )
    SET( OSG_FOUND "TRUE" )
    SET( OPENSCENEGRAPH_FOUND "TRUE" )  # alt name
    MESSAGE( STATUS "Found OpenSceneGraph: ${OSG_LIB_DIR}" )
    # Apply.
    ADD_SYSTEM_INCLUDE_DIR( ${OSG_INC_DIR} )
    LINK_DIRECTORIES( ${OSG_LIB_DIR} )
ELSE()
    MESSAGE( FATAL_ERROR "Could not find OpenSceneGraph" )
ENDIF()
